{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="{:url('user/user_address')}" class="n_tab_list">收货地址列表</a>
            <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
            <div class="cl"></div>
        </div>
        <form class="Huiform" method="post" action="__CONF_SITE__admin/user/user_address" target="_self">
            <div class="text-c"> 收件人：
                <input type="text" class="input-text" value="{$search_text}" style="width:250px" placeholder="输入收件人名称"  name="search_text">
                <button type="submit" class="btn btn-success"  name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
            </div>
        </form>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="9">收货地址列表</th>
            </tr>
            <tr class="text-c">
                <th>ID</th>
                <th>uid</th>
                <th>收件人</th>
                <th>手机号</th>
                <th>地区</th>
                <th>详细地址</th>
                <th>是否默认</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="user_address" id="vo"}
            <tr class="text-c">
                <td>{$vo['id']}</td>
                <td>{$vo['uid']}</td>
                <td>{$vo['consigner']}</td>
                <td>{$vo['phone']}</td>
                <td>{$vo['area']}</td>
                <td>{$vo['address']}</td>
                <td>{if $vo['is_default']==1}是{else/}否{/if}</td>
                <td>{$vo['create_time']}</td>
                <td class="td-manage">
                    <a title="编辑" href="javascript:;" onclick="useraddress_edit('收货地址编辑','useraddress_edit?id={$vo.id}','800','500')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    <a title="删除" href="javascript:;" onclick="useraddress_del(this,'{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$page}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*收货地址-编辑*/
    function useraddress_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*收货地址-删除*/
    function useraddress_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('user/deleteAddressAjax')}",
                data : {
                    "id" : id,
                },
                success : function(data) {
                    console.log(data)
                    if (data > 0) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('删除失败!', {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
</script>
{/block}